package com.evil.common.application.dto.process.node.setting;

import com.evil.common.application.enums.permission.ControlVisibleEnum;
import com.evil.common.core.enums.SwitchEnum;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;

/**
 * 节点控件配置
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
public class NodeControlSettingDTO {

    /**
     * 节点id
     */
    @NotNull(message = "节点id参数不能为空")
    private Long nodeId;

    /**
     * 表单控件id
     */
    @NotNull(message = "表单控件id参数不能为空")
    private Long controlId;

    /**
     * 控件标题
     */
    private String controlTitle;

    /**
     * 新增（0-否，1-是）
     */
    private Integer addStatus;

    /**
     * 编辑（0-否，1-是）
     */
    private Integer modifyStatus;

    /**
     * 删除（0-否，1-是）
     */
    private Integer deleteStatus;

    /**
     * 可见状态(0:不可见, 1:仅可见, 2:可编辑)
     */
    @NotNull(message = "可见状态参数不能为空")
    @Range(min = 0, max = 2, message = "可见状态参数错误")
    private Integer visible;

    public NodeControlSettingDTO() {
        this.addStatus = SwitchEnum.YES.getId();
        this.modifyStatus = SwitchEnum.YES.getId();
        this.deleteStatus = SwitchEnum.YES.getId();
        this.visible = ControlVisibleEnum.EDIT.getId();
    }

    public NodeControlSettingDTO(Long controlId, String controlTitle) {
        this.controlId = controlId;
        this.controlTitle = controlTitle;
        this.addStatus = SwitchEnum.YES.getId();
        this.modifyStatus = SwitchEnum.YES.getId();
        this.deleteStatus = SwitchEnum.YES.getId();
        this.visible = ControlVisibleEnum.EDIT.getId();
    }

    public NodeControlSettingDTO(Long nodeId, Long controlId, String controlTitle, Integer visible) {
        this.nodeId = nodeId;
        this.controlId = controlId;
        this.controlTitle = controlTitle;
        this.addStatus = SwitchEnum.YES.getId();
        this.modifyStatus = SwitchEnum.YES.getId();
        this.deleteStatus = SwitchEnum.YES.getId();
        this.visible = visible;
    }
}
